#pragma once
#include "XmlElement.h"
#include "XmlException.h"

namespace System{
namespace Xml{

class XmlDocument  : public XObject
{
private:
	XmlElementCollection m_Elements;
	char* m_Prolog;

public:
	XmlDocument(void);
	~XmlDocument(void);


public:
	void LoadXml(const PTSTR xmlStr);


private:
	void ParseProlog(PTSTR xml);


	void ParseElement(PPTSTR xml);
	void BeginElement(PPTSTR xml);
	size_t ParseName(PPTSTR xml);


	void ParseAttribute(PPTSTR xml);
	void ParseAttributeValue(PPTSTR xml);



	void ParseStartTag(PPTSTR xml);
	void ParseEndTag(PPTSTR xml);
	void EmptyElementTag(PPTSTR xml);


private:
	bool IsNameStartChar(TCHAR ch);
	bool IsNameChar(TCHAR ch);
	bool IsWhiteSpace(TCHAR ch);

	void SkipComment(PPTSTR xml);


public:
	VIRTUAL_GET_TYPE();
	VIRTUAL_TOSTRING();
};

DEFINE_CLASS_TYPE(System_Xml_XmlDocument, _T("System::Xml::XmlDocument"));

}
}